<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>添加规则</legend>
</fieldset>

<form class="layui-form" action="" lay-filter="example">
    <div class="layui-form-item">
        <label class="layui-form-label">根域名</label>
        <div class="layui-input-block">
            <input type="text" name="domain" lay-verify="required" autocomplete="off" placeholder="请输入网站根域名" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">目标页获取</label>
        <div class="layui-input-block">
            <input type="text" name="targetUrlRegex" lay-verify="required" autocomplete="off" placeholder="请输入目标页获取规则" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">辅助页获取</label>
        <div class="layui-input-block">
            <input type="text" name="helpUrlRegex" lay-verify="required" autocomplete="off" placeholder="请输入辅助页（列表页等）获取规则" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所在区域</label>
        <div class="layui-input-block">
            <input type="text" name="targetUrlModuleRegex" lay-verify="targetUrlModuleRegex" autocomplete="off" placeholder="请输入辅助页中目标页所在区域" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">起始页</label>
        <div class="layui-input-block">
            <input type="text" name="startUrl" lay-verify="required" autocomplete="off" placeholder="请输入起始页" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">作者获取</label>
        <div class="layui-input-block">
            <input type="text" name="authorRegex" lay-verify="authorRegex" autocomplete="off" placeholder="请输入作者获取规则" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">日期获取</label>
        <div class="layui-input-block">
            <input type="text" name="dateRegex" lay-verify="dateRegex" autocomplete="off" placeholder="请输入日期获取规则" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容获取</label>
        <div class="layui-input-block">
            <input type="text" name="contentRegex" lay-verify="contentRegex" autocomplete="off" placeholder="请输入内容获取规则" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">描述获取</label>
        <div class="layui-input-block">
            <input type="text" name="descriptionRegex" lay-verify="descriptionRegex" autocomplete="off" placeholder="请输入描述获取规则" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">分类获取</label>
        <div class="layui-input-block">
            <input type="text" name="catalogRegex" lay-verify="catalogRegex" autocomplete="off" placeholder="请输入分类获取规则" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">标签获取</label>
        <div class="layui-input-block">
            <input type="text" name="tagRegex" lay-verify="tagRegex" autocomplete="off" placeholder="请输入标签获取规则" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图片获取</label>
        <div class="layui-input-block">
            <input type="text" name="imageRegex" lay-verify="imageRegex" autocomplete="off" placeholder="请输入图片获取规则" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">线程个数</label>
        <div class="layui-input-block">
            <input type="text" name="threadCount" lay-verify="required" autocomplete="off" placeholder="请输入线程个数" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">请求UA</label>
        <div class="layui-input-block">
            <select name="userAgent" lay-filter="aihao">
                <option value="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36" selected="">PC</option>
                <option value="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3573.0 Safari/537.36">PC_WIN10</option>
                <option value="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0">PC_FIREFOX64_WIN</option>
                <option value="Mozilla/5.0 (X11; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0">PC_FIREFOX64_LINUX</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">退出方式</label>
        <div class="layui-input-block">
            <select name="exitWay" lay-filter="aihao">
                <option value="DEFAULT" selected="">默认方式(抓完所有)</option>
                <option value="DURATION">爬虫持续的时间</option>
                <option value="URL_COUNT">抓取到的url数量</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">对应的值</label>
        <div class="layui-input-block">
            <input type="text" name="exitWayCount" lay-verify="exitWayCount" autocomplete="off" placeholder="请输入对应退出方式的值" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">超时时间</label>
        <div class="layui-input-block">
            <input type="text" name="sleepTime" lay-verify="required" autocomplete="off" placeholder="请输入每个页面等待时间" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">重试次数</label>
        <div class="layui-input-block">
            <input type="text" name="retryTimes" lay-verify="required" autocomplete="off" placeholder="请输入抓取失败重试次数" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">设置cookie</label>
        <div class="layui-input-block">
            <input type="text" name="cookies" lay-verify="cookies" autocomplete="off" placeholder="请输入需要的cookie xx=xx;xx=xx;" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">设置header</label>
        <div class="layui-input-block">
            <input type="text" name="header" lay-verify="header" autocomplete="off" placeholder="请输入请求的header json格式 {'xx':'xx'}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">标题规则</label>
        <div class="layui-input-block">
            <input type="text" name="titleRegex" lay-verify="titleRegex" autocomplete="off" placeholder="请输入标题规则" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-front-submit" value="确认">
    </div>
<!--    <div class="layui-form-item">
        <div class="layui-input-block">
            <button id="LAY-user-front-submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
        </div>
    </div>-->
</form>

<script src="../../../layuiadmin/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;
        var $ = layui.$;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });
        //监听提交
        // form.on('submit(demo1)', function(data){
        //     $.ajax({
        //         url: '/spider/rule/add',
        //         type: 'POST',
        //         data: data.field,
        //         dataType : "json",
        //         success: function (result) {
        //             if (result.success){
        //                 layer.alert("提交成功");
        //             } else {
        //                 layer.alert("提交失败，原因："+result.message);
        //             }
        //
        //         }
        //     });
        //     return false;
        // });

        //表单初始赋值
        form.val('example', {
            "sleepTime": 10000 // "name": "value"
            ,"retryTimes": 2
            ,"threadCount": 1
            ,"exitWay": "DEFAULT"
            ,"userAgent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36"
        })
    });
</script>

</body>
</html>